POV-Ray Macros: Spherical/Cylindrical Bricks[Author's Homepage] [Author's 
POV-Ray page]



POV-Ray Macros: Spherical/Cylindrical Bricks
By Jeff Lee <shipbrk@gate.net>




[Macro Syntax] [Known Problems] [Download] 



      This include file was originally created to produce hull plating for the 
spherical and cylindrical parts of a space vessel. However, it can also be used 
to easily produce brick patterns which will wrap around a cylinder or sphere. 
      The picture below shows two applications of the macros in the include 
file. Each object shows a cylinder topped by a sphere, with the appropriate 
pattern applied to each component. 
 


      The macros in the include file were designed to meet specific criteria: 
  Individual bricks should retain the same basic height and width regardless of 
  where they occur within the spherical pattern; bricks near the poles of the 
  sphere should not differ significantly in size from the bricks near the 
  equator.


  If the bricks are to have a specific texture (i.e., vertical streaks), then 
  that texture should be rotated appropriately for each brick.


  If the texture for the bricks provides variations in tone, then each brick 
  should be noticeably different from the majority of the neighbouring bricks. 
  This can be made subtler or more noticeable by altering the texture provided 
  to the macros.


Using the Macros 
      The include file plates.inc contains two macros, MakeSphericalPlates and 
MakeCylindricalPlates. The syntax for both macros is identical: 
#declare Tex1 = 
MakeSphericalPlates(MainRad,PWidth,PHeight,JWidth,PlateTex,JoinTex)  
#declare Tex2 = 
MakeCylindricalPlates(MainRad,PWidth,PHeight,JWidth,PlateTex,JoinTex)

      MainRad is the radius of the sphere or cylinder to which the texture will 
be applied. 
      PWidth describes the desired width of the bricks. The macro may slightly 
adjust the actual width of the bricks on a row-by-row basis to avoid the 
inclusion of partial bricks (the full-sized bricks are expanded slightly to fill 
up the row). In spherical patterns, the widest edge of the brick is given the 
full width (the bottom edge if the brick is above the equator, or the top edge 
if the brick is below it). 
      PHeight describes the desired height of the bricks. As with PWidth, the 
macro may adjust this value (if creating a spherical brick pattern) to ensure 
that all rows are the same height. (Height is measured from the "top" edge of 
the brick to the "bottom", not just its Y-axis value.) 
      JWidth is the width and height of the joins (or mortar) between the plates 
or bricks. Half of this value is removed from the left and right sides of each 
brick, and also from the top and bottom. 
      PlateTex is the texture to be applied to the plates or bricks. If this is 
to be a definite pattern, such as a grid, hexagons, horizontal or vertical 
stripes, make sure the texture is aligned so that it lies in the XY plane, 
facing towards -Z; it will be rotated so that it lies on the face of each brick 
in the pattern, and translated by a certain amount so that each brick shows 
variations from its neighbours. 
      JoinTex is the texture to be applied to the joins (mortar) between the 
plates. It is not rotated like PlateTex is. 


      NOTE: The texture will be created at the origin. If the object to which it 
is to be applied is not also centred at the origin, you will have to translate 
and/or rotate the texture into the proper position. 
Known Problems 
      Due to a size limitation in POV-Ray's blend map, large spheres with small 
bricks may cause POV-Ray to abort processing. To avoid this, ensure that the 
bricks' vertical size (PHeight) is not under 2.5% of MainRad (which permits at 
most 128 rows from the top of the sphere to the bottom). Another workaround is 
to set JWidth to 0 (zero), which permits twice as many rows of bricks (at the 
cost of visible mortar). There is no such restriction on the horizontal size of 
the bricks, as the macros use the frequency modifier to overcome this particular 
limitation. 
      Although the cylindrical brick pattern staggers the bricks evenly from row 
to row, this is not possible with the spherical pattern. There will be spots 
where the bricks appear to line up vertically with the bricks above or below 
them, and will gradually shift to staggered patterns. This is an inevitable 
result of keeping the bricks at the same basic size; it is not a programming 
error. 
      Because the macros do a lot of math, and there's a fair amount of scaling, 
translating and rotating, these textures can take some time to parse and render. 

Download 
      The zip archive below contains the plates.inc include file, a sample scene 
(plates.pov) and basic documentation. If you choose to distribute these macros 
(for example, if they are integral to a model or scene you make publicly 
available), please distribute only unaltered versions and ensure that at least 
the include file and its documentation are present. 
[Download plates.zip (5K)] 



[Author's Homepage] [Author's POV-Ray page]

